<?php
namespace App\Repositories\System;
use App\Common\Utils\BaseRepository;
use App\Models\SystemTask;

/**
 * 参加人员信息
 */
class SystemTaskRepository extends BaseRepository
{
    protected $model;

    public function __construct(SystemTask $systemTask)
    {
        $this->model = $systemTask;
    }

    /**
     * @Description: 待办信息获取
     * @Author: kzj
     * @datetime: 2023-03-02
     */
    public function getTaskInfo($formKey, $req, $type = 'check')
    {
        $name = '';
        $url = '';
        $menuId = 0;

        $typeName = "待办";
        switch($type) {
            case "check":
                $typeName = '审核';
                break;
            case "edit":
                $typeName = '审核驳回';
                break;
        }

        switch($formKey) {
            case "TEARRESEARCH_OPEN_TABLE":
                $name = '教育教学-公开教学【教学】' . $typeName;
                $url = '/teaching/open/' . $type;
                $menuId = $type == 'edit' ? 216 : 217;
                break;
            case "EW_CLASS_MEETING_TABLE":
                $name = '教育教学-公开教学【教育】' . $typeName;
                $url = '/teaching/open/' . $type;
                $menuId = $type == 'edit' ? 216 : 217;
                break;
            case "TEARRESEARCH_EXCHANGE_TABLE":
                $name = '教育教学-经验交流【教学】' . $typeName;
                $url = '/teaching/experience/' . $type;
                $menuId = $type == 'edit' ? 221 : 222;
                break;
            case "EW_EXCHANGE_EXPERIENCE_TABLE":
                $name = '教育教学-经验交流【教育】' . $typeName;
                $url = '/teaching/experience/' . $type;
                $menuId = $type == 'edit' ? 221 : 222;
                break;
            case "TEARRESEARCH_SUBJECT_STUDY_TABLE":
                $name = '教育教学-课题研究【教学】' . $typeName;
                $url = '/teaching/study/' . $type;
                if($type == 'check') {
                    $menuId = 227;
                } else if($type == 'edit') {
                    $menuId = 226;
                } else {
                    $menuId = 229;
                }
                break;
            case "EW_SUBJECT_RESEARCH_TABLE":
                $name = '教育教学-课题研究【教育】' . $typeName;
                $url = '/teaching/study/' . $type;
                if($type == 'check') {
                    $menuId = 227;
                } else if($type == 'edit') {
                    $menuId = 226;
                } else {
                    $menuId = 229;
                }
                break;
            case "TEARRESEARCH_PUBLISH_TABLE":
                $t = $req['pubications_publish_type'] == '128' ? '论文发表' : '论著发表';
                $name = '教育教学-' . $t . '【教学】' . $typeName;
                $url = $req['pubications_publish_type'] == '128' ? '/teaching/paper/' . $type : '/teaching/treatise/' . $type;
                if($type == 'edit') {
                    $menuId = $req['pubications_publish_type'] == '128' ? 232 : 237;
                } else {
                    $menuId = $req['pubications_publish_type'] == '128' ? 233 : 238;
                }
                break;
            case "EW_PAPER_PUBLISH_TABLE":
                $t = $req['pubications_publish_type'] == '128' ? '论文发表' : '论著发表';
                $name = '教育教学-' . $t . '【教育】' . $typeName;
                $url = $req['pubications_publish_type'] == '128' ? '/teaching/paper/' . $type : '/teaching/treatise/' . $type;
                if($type == 'edit') {
                    $menuId = $req['pubications_publish_type'] == '128' ? 232 : 237;
                } else {
                    $menuId = $req['pubications_publish_type'] == '128' ? 233 : 238;
                }
                break;
            case "TEARRESEARCH_DEVELOP_SUBJECT_TABLE":
                $name = '教育教学-开发科目' . $typeName;
                $url = '/teaching/subject/' . $type;
                $menuId = $type == 'edit' ? 242 : 243;
                break;
            case "EW_SOCIAL_PRACTICE_TABLE":
                $name = '实践活动-社会实践' . $typeName;
                $url = '/education/practice/' . $type;
                $menuId = $type == 'edit' ? 269 : 270;
                break;
            case "EW_THEME_ACTIVITY_TABLE":
                $name = '实践活动-主题活动' . $typeName;
                $url = '/education/theme/' . $type;
                $menuId = $type == 'edit' ? 279 : 280;
                break;
            case "TEACHERTRAINING_DEVELOPCOURSE_TABLE":
                $name = '教师培训-开发课程' . $typeName;
                $url = '/faculty/courses/' . $type;
                $menuId = $type == 'edit' ? 284 : 285;
                break;
            case "TEACHERTRAINING_JOINTRAINING_TABLE":
                $name = '教师培训-参与教研' . $typeName;
                $url = '/faculty/research/' . $type;
                $menuId = $type == 'edit' ? 312 : 313;
                break;
            case "TEACHERTRAINING_OUTTRAINING_TABLE":
                $name = '教师培训-外出培训' . $typeName;
                $url = '/faculty/outraining/' . $type;
                $menuId = $type == 'edit' ? 291 : 292;
                break;
            case "TEACHERTRAINING_OTHER_TABLE":
                $name = '教师培训-其他培训' . $typeName;
                $url = '/faculty/other/' . $type;
                $menuId = $type == 'edit' ? 296 : 297;
                break;
            case "TEACHING_PROJECT_TABLE":
                $name = '教育教学-项目化' . $typeName;
                $url = '/teaching/project/' . $type;
                $menuId = $type == 'edit' ? 296 : 297;//
                break;
            case "TEACHING_TEACHER_TABLE":
                $name = '教育教学-全员导师制' . $typeName;
                $url = '/teaching/teacher/' . $type;
                $menuId = $type == 'edit' ? 296 : 297;//
                break;
            case "TEACHING_REFLECT_TABLE":
                $name = '教育教学-教学反思(案例)' . $typeName;
                $url = '/teaching/teacher/' . $type;
                $menuId = $type == 'edit' ? 402 : 297;//
                break;
        }

        if(!$name) {
            throw new \Exception('获取待办名称失败，请核实！');
        }

        $result = [
            'name' => $name,
            'url' => $url,
            'menu_id' => $menuId
        ];

        return $result;
    }

}
